/*
 * @Author: Siyongkun
 * @Date: 2021-07-24 12:17:39
 * @Last Modified by: Siyongkun
 * @Last Modified time: 2021-07-24 12:27:01
 */
import { Component } from 'react';
import BScroll from 'better-scroll';
import './city.css';
class city extends Component<any> {
  scroller: any;
  static defaultProps = {
    scrollbar: true,
    top: 25,
    bottom: 0,
  };
  componentDidMount() {
    const re: any = this.refs[this.props.refName];
    this.scroller = new BScroll(re, {
      scrollbar: this.props.scrollbar,
      bounce: true,
      probeType: 1,
      click: true,
    });
  }
  refresh() {
    this.scroller.refresh();
  }
  scrollElement(ele: any) {
    this.scroller.scrollToElement(`.${ele}`);
  }
  render() {
    return (
      <div
        ref={this.props.refName}
        className="scroller-wraper"
        style={{ top: this.props.top, bottom: this.props.bottom }}
      >
        <div>{this.props.children}</div>
      </div>
    );
  }
}
export default city;
